<template>
  <div>
    <van-field v-model="form.name" label="姓名"></van-field>
    <van-field v-model="form.money" label="金额"></van-field>
    <van-field v-model="form.company_name" label="机构名称"></van-field>
    客户经理
    <select  v-model="form.manger_id">
      <option :value="i.id" v-for="i in customer_manager" :key="i.id">{{ i.name }}</option>
    </select>
    注册来源
    <select  v-model="form.refromid">
      <option :value="i.id" v-for="i in refromidlist" :key="i.id">{{ i.name }}</option>
    </select>
    <van-button @click="post_customer">提交</van-button>
    <p></p>
    {{this.form}}

    <ul v-for="i in data" :key="i.id">
      <li>姓名:{{ i.name }}
      </li>
      <li>金额:{{ i.money }}</li>
      <li>机构名称:{{ i.company_name }}</li>
      <li>客户经理:{{ i.manger_id }}</li>
      <li>注册来源:{{ i.refromid }}</li>
      <br>
    </ul>

  </div>
</template>

<script>
import axios from 'axios'

export default {
  name: "customer",
  data() {
    return {
      data: {},
      form: {},
      customer_manager: [],
      refromidlist:[]
    }
  },
  methods: {
    get_customer() {
      axios.get('/customer', 'get')
          .then(res => {
            this.data = res.data.list
          })
    },
    post_customer() {
      axios.post('/post_cus', this.form)
          .then(res => {
            console.log(res)
          })
    },
    get_customer_manager() {
      axios.get('/get_customer_manager', 'get')
          .then(res => {
            this.customer_manager = res.data.list
            console.log(res)
          })
    },
    get_refromid() {
      axios.get('/get_refromid', 'get')
          .then(res => {
            this.refromidlist = res.data.list
            console.log(res)
          })
    },
  },
  mounted() {
    this.get_customer()
    this.get_customer_manager()
    this.get_refromid()
  }
}
</script>

<style scoped>

</style>
